package vfs.persist.association.impl;

import java.sql.Connection;
import vfs.filter.VFSFilter;
import vfs.obj.entity.VFSGroup;
import vfs.obj.entity.VFSNode;
import vfs.persist.association.VFSNodeWritableByGroupManager;
import vfs.persist.entity.build.impl.VFSGroupBuilder;
import vfs.persist.entity.build.impl.VFSNodeBuilder;
import java.util.Iterator;

/**
 *
 * @author Matthew Eavenson <durandal@uga.edu>
 */
public class VFSNodeWritableByGroupManagerImpl implements VFSNodeWritableByGroupManager{
    
    private VFSAssociationManagerImpl<VFSNode, VFSGroup> am;
    
    public VFSNodeWritableByGroupManagerImpl(Connection conn){
        am = new VFSAssociationManagerImpl<VFSNode, VFSGroup>(conn, new VFSNodeBuilder(), 
                                                 new VFSGroupBuilder(), 
                                        "vfsNode", null, "writableBy");
    }
    
    @Override
    public Iterator<VFSNode> getNodes(VFSGroup group, VFSFilter filter){
        return am.findTM1(group, filter);
    }
    
    @Override
    public VFSGroup getGroup(VFSNode node){
        return am.findUM1(node);
    }
    
    @Override
    public void setGroup(VFSNode node, VFSGroup group){
        am.persistM1(node, group);
    }
    
}
